<?php 
namespace Admin\Controller;
use Common\Controller\AdminBaseController;
class MenuController extends AdminBaseController{
	public function index(){
		$menu = D('menu');
		$list = $menu -> Menulist(0,'id,pid,title,link,sort,status','sort');
		$list = _getTree($list['data'],0,0,'|--');
		$this -> assign('list',$list);
		$this -> display();
	}
	
	public function save(){
		if(IS_POST || IS_AJAX){
			$menu = D('menu');
			$result = $menu -> addMysql(I('post.'));//对前台的数据进行全部添加
			// echo $result;exit;
			$this -> ajaxReturn($result);
		}
		
	}

	public function del(){
		if(IS_POST){
			$result = D('menu') -> delMenu(I('post.id/d',0));
			$this -> ajaxReturn($result);
		}
	}

	public function getMenu(){
		if(IS_POST){
			$result = D('menu') -> Menulist(I('post.id/d',0),'id,pid,title,link,sort,status'); 
			$this -> ajaxReturn($result);
		}
	}



	public function AlterState(){
		if(IS_POST){
			$result = D('menu') -> AlterState(I('post.id/d',0));
			$this -> ajaxReturn($result);
		}
	}





}




